<?php

namespace App\Models;

use App\Libs\DataFormat;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Volunteer extends Model
{

    use DataFormat;

    protected $table = 'volunteer';
    protected $dates = [''];

    //protected $guarded = ['id', 'created_at'];
    protected $fillable = [ 'user_id', 'org_id', 'real_name', 'nation', 'sex', 'birthday', 'phone', 'identifier', 'slogan', 'reward_time', 'id_number', 'province_id', 'province_name', 'city_id', 'city_name', 'county_id', 'county_name', 'addr', 'family_id', 'join_family_time', 'last_login_time', 'score', 'relation', 'extends'];


    public static  $formatKey = ['real_name'=>'string', 'nation'=>'string', 'sex'=>'int', 'birthday'=>'string', 'identifier'=>'string', 'slogan'=>'string', 'reward_time'=>'string', 'id_number'=>'string', 'province_id'=>'int', 'province_name'=>'string', 'city_id'=>'int', 'city_name'=>'string', 'county_id'=>'int', 'county_name'=>'string', 'addr'=>'string', 'family_id'=>'int', 'join_family_time'=>'string','score'=>'int', 'in_blacklist'=>'int', 'relation'=>'string', 'extends'=>'json_decode', 'stars'=>'int'];

    protected $casts = [
        'extends' => 'array',
    ];

    public function user()
    {
        return $this->hasOne('App\Models\User', 'id', 'user_id');
    }

}
